gusucode.com > 支持向量机工具箱 - LIBSVM OSU_SVM LS_SVM源码程序 > 支持向量机工具箱 - LIBSVM OSU_SVM LS_SVM\stprtool\bayes\pbayescln.m

    function pbayescln(MI,SIGMA,Pk,background, linestyle)
% PBAYESCLN vizualizes Bayes classifier discriminant in 2D.
%  pbayescln(MI,SIGMA,Pk,background, linestyle )
%
% This fucntion vizualizes discriminant functions of 
% Bayes classifier (see help bayescln). 
%
% Intput:
%  (notation: K - number of classes)
%  MI [2xK] Matrix of K vectors of mean values of p(x|k).
%    MI=[mi_1,mi_2,...,mi_K], where mi_j is a column vector [Nx1] for 
%    class j.
%  SIGMA [(2x2)xK] Matrix of covariance matrices of the density p(x|k).
%    SIGMA=[sigma_1,sigma_2,...,sigma_K], sigma_j is the covariance
%    matrix corresponding to the class j.
%  Pk [1xK] Vector with a priori probability densities. Pk(j) is an
%    a priori probability of class j.
%  background [1x1] if is 0 then only the border (discriminat fce = 0) 
%    is displayed. If is 1 (default) then the colors of background 
%    correspond to values of discriminant function. 
%  linestyle [string] used line style (see help plot).
%
% Output:
%  Graph to current figure.
% 
% See also BAYESCLN, PDISCRIM.
% 

% Statistical Pattern Recognition Toolbox, Vojtech Franc, Vaclav Hlavac
% (c) Czech Technical University Prague, http://cmp.felk.cvut.cz
% Written Vojtech Franc (diploma thesis) 23.12.1999, 5.4.2000
% Modifications
% 20-may-2001, V. Franc, created

if nargin < 4 | isempty(background),
  background = 1;
end

if nargin < 5,
  linestyle = 'k';
end

% grid
GRIDX=50;
GRIDY=50;

if nargin < 3,
   error('Not enough input arguments.');
   return;
end

V = axis;
dx = (V(2)-V(1))/GRIDX;
dy = (V(4)-V(3))/GRIDY;

[X,Y] = meshgrid(V(1):dx:V(2),V(3):dy:V(4));

% make testing points
Xtst=[reshape(X',1,prod(size(X)));reshape(Y',1,prod(size(Y)))];

% classify points
[Ixy, D] = bayescln(Xtst,MI,SIGMA,Pk);

pdiscrim( D, V(1):dx:V(2), V(3):dy:V(4), background, linestyle );

axis(V);

return;